package comxin.demo1.jdbcdemo;

import comxin.demo1.Utils.JdbcUtils;

import java.sql.*;

public class preparedemo_01 {
    public static void main(String[] args) {
        Connection conn=null;
        PreparedStatement psta=null;
        ResultSet re=null;
        try {
            conn= JdbcUtils.getConnection();
            String sql="update idpassword set `password`='admin22' where `username`=?";
            psta=conn.prepareStatement(sql);
            psta.setString(1,"admin");
            int i = psta.executeUpdate();
            System.out.println(i==1?"执行成功":"执行失败");
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JdbcUtils.close(conn,psta,re);
        }
    }
}
